<template>
  <!-- 树形控件 -->
  <el-tree ref="menuTree" :data="menus" :props="defaultProps" node-key="catId" :expand-on-click-node="false" @node-click="handleNodeClick">
  </el-tree>
</template>

<script>
export default {
  data() {
    return {
      menus: [],
      defaultProps: {
        children: "children",
        label: "name",
      }
    };
  },
  methods: {
    // 获取数据列表
    getMenuList() {
      this.$http({
        url: this.$http.adornUrl("/product/category/list/tree"),
        method: "get",
      }).then(({ data }) => {
        this.menus = data.data;
      });
    },
    handleNodeClick(data) {
      this.$emit("tree-node-click", data);
    }
  },
  mounted() {
    this.getMenuList();
  }
}
</script>

<style>
</style>